﻿@model Inscriptionem.Areas.Inscriptionem.Models.Views.SectionViewModel

@{
    ViewBag.Title = "Inscriptionem » Sections » Edit Section";
    Layout = "../Shared/Layout.cshtml";

    ViewBag.CurrentPage = "Sections";

    string message = string.Empty;

    switch (Model.Error)
    {
        case Inscriptionem.Areas.Inscriptionem.Models.Enums.SectionError.SectionEmpty:
            {
                message = "Please enter Section.";
                break;
            }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.SectionError.SectionLocalizationEmpty:
            {
                message = "Please enter Section Name.";
                break;
            }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.SectionError.SectionLanguageEmpty:
            {
                message = "Please enter Section Language.";
                break;
            }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.SectionError.SectionAlreadyExists:
            {
                message = "Section already exists, try another one.";
                break;
            }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.SectionError.OrderNotValid:
            {
                message = "Please enter valid order, a positive number.";
                break;
            }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.SectionError.OrderAlreadyInUse:
            {
                message = "Entered order already in use by another Section, please enter different value.";
                break;
            }

        case Inscriptionem.Areas.Inscriptionem.Models.Enums.SectionError.Other:
            {
                message = "Unknown error occurred, please try again.";
                break;
            }
    }
}

<div class="outer" id="contentwrap">
    @{Html.RenderPartial("NavigationMenu");}
    <div class="postcont">
		<div id="content">
            <div class="post type-post status-publish format-standard hentry">
                <h2 class="title">Edit Section</h2>
                <div class="postdate-single error-message">@message</div>
                <hr />
                <form method="post" action="/Inscriptionem/Section/Edit">
                    <input type="hidden" name="ID" value="@Model.ID" />
				    <div class="entry">
                        <p>Order <input type="text" name="Order" value="@Model.Order" /></p>
                        <p>Section <input type="text" name="Name" value="@Model.Name" /></p>
                        <p>Section Name <input type="text" name="LocalizedName" value="@Model.LocalizedName" /></p>
                        <p>Default <input type="checkbox" name="IsDefault" @(Model.IsDefault ? "checked" : string.Empty) /></p>
                        <p>Language
                            <select name="Language">
                            @foreach (var language in Model.Languages)
                            { 
                            <text>
                            <option value="@language.ID" @(language.ID == Model.Language ? "selected" : string.Empty)>@language.Name / @language.LocalizedName</option>
                            </text>
                            }
                            </select>
                        </p>
	                </div>

                    <input type="reset" value="Reset" />&nbsp;|&nbsp;<input type="submit" value="Save" />
                </form>
			</div>
        </div>
	</div>	
</div>
